<#assign ctx=springMacroRequestContext.contextPath/>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title></title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="${ctx}/style/font/font.css"/>
    <link rel="stylesheet" href="${ctx}/plugin/layui/css/layui.css"/>
    <link rel="stylesheet" href="${ctx}/plugin/layer/theme/default/layer.css"/>
</head>
<body>
<input id="basePath" type="hidden" value="${ctx}"/>
<form class="layui-form" id="saveFtpForm">
    <br>
    <div class="layui-form-item">
        <label class="layui-form-label">FTP协议</label>
        <div class="layui-input-inline" style="margin-right: 30px">
            <select name="ftpType" id="ftpType" lay-verify="required">
                <option value="">---请选择---</option>
                <option value="1">ftp 协议</option>
                <option value="2">ftps协议</option>
                <option value="3">sftp协议</option>
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">FTP名称</label>
        <div class="layui-input-inline" style="margin-right: 30px">
            <input type="text" class="layui-input" placeholder="请输入FTP名称"
                   lay-verify="required" name="ftpName" id="ftpName" autocomplete="off">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">FTP用户</label>
        <div class="layui-input-inline" style="margin-right: 30px">
            <input type="text" class="layui-input" placeholder="请输入FTP名称"
                   lay-verify="required" name="ftpUser" id="ftpUser" autocomplete="off">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">FTP密码</label>
        <div class="layui-input-inline" style="margin-right: 30px">
            <input type="text" class="layui-input" placeholder="请输入FTP密码"
                   lay-verify="required" name="ftpPass" id="ftpPass" autocomplete="off">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">FTP地址</label>
        <div class="layui-input-inline" style="margin-right: 30px">
            <input type="text" class="layui-input" placeholder="请输入FTP地址"
                   lay-verify="required" name="ftpHost" id="ftpHost" autocomplete="off">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">FTP端口</label>
        <div class="layui-input-inline" style="margin-right: 30px">
            <input type="text" class="layui-input" placeholder="请输入FTP端口"
                   lay-verify="required|number" name="ftpPort" id="ftpPort" autocomplete="off">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">FTP模式</label>
        <div class="layui-input-inline" style="margin-right: 30px">
            <select name="ftpMode" id="ftpMode" lay-verify="required">
                <option value="">---请选择---</option>
                <option value="1">PORT主动方式</option>
                <option value="2">PASV被动方式</option>
            </select>
        </div>
    </div>
    <div class="layui-form-item" style="text-align:center; width:100%;position:fixed; bottom:0;">
        <input type="button" value="添加" class="layui-btn layui-btn-sm" lay-filter="saveFtpBtn" lay-submit/>
        <input type="button" id="backFtpBtn" value="取消" class="layui-btn layui-btn-sm layui-btn-warn"/>
    </div>
</form>

<script type="text/javascript" src="${ctx}/plugin/jquery/jquery.min-1.9.1.js"></script>
<script type="text/javascript" src="${ctx}/plugin/layui/layui.js"></script>
<script type="text/javascript" src="${ctx}/plugin/layer/layer.js"></script>
<script>
    var basePath = $("#basePath").val();
    $(document).ready(function () {
        layui.use('form', function () {
            var form = layui.form;
            //渲染表单
            form.render();
            //监听提交
            form.on('submit(saveFtpBtn)', function (data) {
                submitSaveFtpForm();
                return false;
            });

        });

        //注册监听事件
        $("#backFtpBtn").on("click", function () {
            //关闭弹出层
            var index = parent.layer.getFrameIndex(window.name);
            parent.layer.close(index);
        });

    });

    function submitSaveFtpForm() {
        $.ajax({
            type: "post",
            url: basePath + '/rtb/ftp/insert',
            data: $('#saveFtpForm').serialize(),
            success: function (data) {
                layer.alert(data.msgs, {
                    skin: 'layui-layer-molv',
                    closeBtn: 0
                }, function () {
                    //关闭弹出层
                    var index = parent.layer.getFrameIndex(window.name);
                    parent.layer.close(index);
                    //刷新父页面
                    parent.location.reload();
                });
            }
        });
    }
</script>
</body>
</html>